package com.smartcaliper.base;

import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Window;
import android.view.WindowManager;

import com.readystatesoftware.systembartint.SystemBarTintManager;
import com.smartcaliper.MyActivityManager;
import com.smartcaliper.R;
import com.smartcaliper.util.ScreenUtils;

/**
 * Created by censen on 2016/4/10.
 */
public class BaseMainActivity extends FragmentActivity {

    protected Context mContext;
    SystemBarTintManager tintManager;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        String className = this.getClass().getSimpleName();
        mContext = this;
        MyActivityManager.getScreenManager().pushActivity(this);
        tintManager = new SystemBarTintManager(this);

    }

    @Override
    protected void onResume() {
        super.onResume();


    }

//    @Override
//    public void onPostCreate(Bundle savedInstanceState) {
//        super.onPostCreate(savedInstanceState);
//
//    }
//    @Override
//    protected void attachBaseContext(Context newBase) {
//        super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
//    }



    @Override
    public void startActivity(Intent intent) {
        super.startActivity(intent);
        overridePendingTransition(R.anim.push_right_in,
                R.anim.push_right_out);
    }

    public void startActivityForResult(Intent intent, int requestCode) {
        super.startActivityForResult(intent, requestCode);
        overridePendingTransition(R.anim.push_right_in,
                R.anim.push_right_out);
    }

    protected void onDestroy(){
        super.onDestroy();
        MyActivityManager.getScreenManager().popActivity(this);


    }

    @Override
    public void finish() {
        super.finish();
        overridePendingTransition(R.anim.push_left_in,
                R.anim.push_left_out);
    }


    public void applyTransSystemBar() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            Window win = getWindow();
            win.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            SystemBarTintManager tintManager = new SystemBarTintManager(this);
            tintManager.setStatusBarTintEnabled(true);
            tintManager.setStatusBarTintResource(R.color.main_ui_systembar_color);
        }
    }


    public void applyLeftMenuSystemBar() {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintResource(R.color.menu_systembar_color);

    }

    public void applySystemBarColor(int colorRes) {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintResource(colorRes);
        ScreenUtils.setStatusBarDarkIcon(this,true);

    }



}
